package com.tool_stdy.utils.DataSource;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.mchange.v2.c3p0.ComboPooledDataSource;

public class TestDB {

    public static void testCon() throws SQLException, InterruptedException {
        ComboPooledDataSource ds = new ComboPooledDataSource();
        Connection conn = ds.getConnection();
        System.out.println(ds.getMaxPoolSize());
        PreparedStatement prepareStatement = conn.prepareStatement("select * from test where age=?");
        prepareStatement.setInt(1, 20);
        ResultSet result = prepareStatement.executeQuery();
        while (result.next()) {
            System.out.println(result.getString("name"));
        }
        conn.close();
        System.out.println(conn);
    }
    public static void testDataPool(Long buid) throws SQLException, InterruptedException{

        ComboPooledDataSource ds = new ComboPooledDataSource();
        Thread.sleep(12000);
        String sql = "delete from t_sms_template where buid=?";
        Connection conn = ds.getConnection();
        PreparedStatement prepareStatement = conn.prepareStatement(sql);
        prepareStatement.setLong(1, buid);
        int executeUpdate = prepareStatement.executeUpdate();
        System.out.println(executeUpdate);

    }

    
    public static void testupdate(Long buid) throws SQLException, InterruptedException{

        ComboPooledDataSource ds = new ComboPooledDataSource();
        String sql = "UPDATE t_jobcv_relation SET cuid = ?, cvid=? where buid=?";
        Connection conn = ds.getConnection();
        PreparedStatement prepareStatement = conn.prepareStatement(sql);
        prepareStatement.setString(1, "dd");
        prepareStatement.setString(2, "dd");
        prepareStatement.setLong(3, buid);
        int executeUpdate = prepareStatement.executeUpdate();
        System.out.println(executeUpdate);

    }
    public static void main(String[] args) throws SQLException, InterruptedException {
       // testCon();
       // testDataPool(new Long(2));
        testupdate(new Long(123));
    }
}
